/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itschapala.dsw2.llantas.Bl;

import javax.ejb.Stateless;
import mx.itschapala.dsw2.llantas.dao.ArticulodaoLocal;
import mx.itschapala.dsw2.llantas.modelo.Articulo;

/**
 *
 * @article VENUMLEO
 */
@Stateless
public class ArticuloBl implements ArticuloBlLocal {
private ArticulodaoLocal articulodao;
    @Override
    public void register(Articulo article) {
    if(articulodao.findDuplicity(article)){
           return EstadoServicio.INCOMPLETE;
            //nada
        }else{
            articulodao.create(article);
            return EstadoServicio.COMPLETE;
        }
    }

    @Override
    public EstadoServicio delete(Articulo article) {
        f(article.getidarticulo()==null||articuloDao.find(article.getidarticulo())==null){
            return EstadoServicio.INCOMPLETE;
        }else{
        articuloDao.edit(article);
           return EstadoServicio.COMPLETE;
    }
    }

    @Override
    public EstadoServicio modify(Articulo article) {
        if(article.getidarticulo()==null||articuloDao.find(article.getidarticuloarticulo())==null){
            return EstadoServicio.INCOMPLETE;
        }else{
        articuloDao.edit(article);
           return EstadoServicio.COMPLETE;
    }
    }

    @Override
    public Articulo findById(Integer id) {
        return articuloDao.find(id);
    }

}
